package com.example.ndkjnidemo.dashboard;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;

import com.example.ndkjnidemo.R;
import com.example.ndkjnidemo.databinding.FragmentDashboardBinding;
import com.example.ndkjnidemo.dashboard.bitmap.BitmapActivity;
import com.example.ndkjnidemo.dashboard.bitmap.BitmapBlackWhiteActivity;
import com.example.ndkjnidemo.dashboard.bitmap.BitmapDealActivity;


public class DashboardFragment extends Fragment implements View.OnClickListener {

    private DashboardViewModel dashboardViewModel;
    private FragmentDashboardBinding binding;

    public View onCreateView(@NonNull LayoutInflater inflater,
                             ViewGroup container, Bundle savedInstanceState) {
        //===
        dashboardViewModel =
                new ViewModelProvider(this, new ViewModelProvider.NewInstanceFactory()).get(DashboardViewModel.class);
        //===
        binding = FragmentDashboardBinding.inflate(inflater, container, false);
        View root = binding.getRoot();
        //===
        binding.btnBitmap.setOnClickListener(this);
        binding.btnBitmap2.setOnClickListener(this);
        binding.btnBitmapBlackwhite.setOnClickListener(this);
        //===
        return root;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        binding = null;
    }

    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.btn_bitmap) {
            startActivity(new Intent(getActivity(), BitmapActivity.class));
        } else if (v.getId() == R.id.btn_bitmap2) {
            startActivity(new Intent(getActivity(), BitmapDealActivity.class));
        } else if (v.getId() == R.id.btn_bitmap_blackwhite) {
            startActivity(new Intent(getActivity(), BitmapBlackWhiteActivity.class));
        }
    }

}